<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
//微信
Route::group(['namespace' => 'Wechat', 'prefix' => '/', 'middleware' => ['wechat.oauth', 'wechat']], function () {
//    Route::group(['middleware' => ['wechat.oauth', 'wechat']], function () {
    require 'wechat/shop.php';
//    });
});

//后台
//上传图片
Route::resource('photo', 'PhotoController', ['only' => ['store']]);
//后台
Route::group(['prefix' => 'admin'], function () {
    Auth::routes();
    Route::get('/github', 'HomeController@redirectToProvider')->name('github');
    Route::get('/callback', 'HomeController@handleProviderCallback')->name('callback');
    Route::get('/mail', 'HomeController@mail')->name('mail');
    Route::get('/home', 'HomeController@index')->name('home');
    Route::group(['namespace' => 'Admin', 'middleware' => ['auth', 'sidebar', 'role']], function () {
        Route::get('/index', 'IndexController@index')->name('admin');//主页
        require 'admin/shop.php';//商品
        require 'admin/system.php';//系统设置
        require 'admin/location.php';//地图
        require 'admin/ads.php';//广告管理
        /***
         * 后台微信菜单设置
         * 1.首先进入easyWeChat官网，找到laravel的安装一节。
         * 2.执行命令安装easyWeChat第三方sdk，按要求注册服务和门面并生成WeChat.php配置文件。
         * 3.在.env文件中配置微信公众号基本信息。
         * 4.配置微信菜单路由，并创建对应的控制器。
         * 5.参考easyWeChat文档中的菜单一节，控制器中use easyWeChat类，根据需求进行增删改查。
         */
        Route::group(['prefix' => 'wechat', 'namespace' => 'Wechat', 'as' => 'wechat.'], function () {
            //微信自定义菜单
            Route::group(['prefix' => 'menu'], function () {
                Route::get('edit', 'MenuController@edit')->name('menu.edit');
                Route::put('update', 'MenuController@update')->name('menu.update');
                Route::delete('destroy', 'MenuController@destroy')->name('menu.destroy');
            });
        });
    });
});

